package com.gin.kotlin.no_gay_alliance.adapter.user

import android.content.Context
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingRecyclerViewAdapter
import com.gin.kotlin.no_gay_alliance.base.MyHandler
import com.gin.kotlin.no_gay_alliance.databinding.ItemTextBinding
import com.gin.kotlin.no_gay_alliance.model.UserDetailModel
import com.gin.kotlin.no_gay_alliance.utils.TimeUtils.Companion.FULL_DATE_TIME_FORMATTER

class UserRemarkAdapter(context: Context, handler: MyHandler, data: MutableList<UserDetailModel.UserRemarkModel> = mutableListOf()) :
    AbstractBindingRecyclerViewAdapter<ItemTextBinding, UserDetailModel.UserRemarkModel>(context, handler, false, data) {
    /**
     * 当显示某一位置的item时的操作
     * @param holder ViewHolder
     * @param position Int
     * @param b ViewBinding
     * @param dataModel 数据对象
     */
    override fun onBindViewHolder(holder: ViewHolder<ItemTextBinding>, position: Int, b: ItemTextBinding, dataModel: UserDetailModel.UserRemarkModel) {
        val time = dataModel.timestamp?.let { FULL_DATE_TIME_FORMATTER.format((it)) }?.let { " 自 $it" }
        b.root.text = "[${dataModel.text}]" + time
    }
}